<?php require_once('../../core/import.php');?>
<?php User::Permission('ENTERPRISE_STAR'); ?>
<?php
    if($_SERVER['REQUEST_METHOD']=='POST')
    {
         #图片处理
        $Result=Upload::Probe($_FILES['File'],Config::UPLOAD_ATTACHMENT_SIZE_IMAGE,Config::UPLOAD_ATTACHMENT_EXT_IMAGE,Config::PATH_UPLOAD_ATTACHMENT_TEMP);
        
        #上传处理
        $Filename=NULL;
        if($Result['error']==UPLOAD_ERR_NO_FILE)    //如果上传了文件
        {
			echo '1|请上传图片';
        }
		else
		{
            switch($Result['error'])
            {
				//正确上传
                case UPLOAD_ERR_OK:
					//-更新数据
                    $Filename=Upload::Execute($_FILES['File'],Config::PATH_UPLOAD_ATTACHMENT_TEMP);									
					$ID=Functions::FormArgs('ID');
					DB::UpdateRowByID('enterprise_star',$ID,array
					(
						'PicturePath'=>$Filename
					));					
					echo '0|'.Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$Filename;	
                break;
				//扩展名不正确
                case Upload::UPLOAD_ERR_CUSTOM_EXT:
                    echo '2|'.join(',',Upload::$UPLOAD_EXT_IMAGE);
                break;
				//图片大小不正确
                case Upload::UPLOAD_ERR_CUSTOM_SIZE:
                    echo '3|'.Functions::SizeFormat(Config::UPLOAD_ATTACHMENT_SIZE_IMAGE);
                break;
				//意外错误
                default :
                    echo '4|错误代码：'.$Result['error'].'，错误描述：'.$Result['message'].'。"}';
            }			
		}	
	}
?>